import React from 'react';
import { BrowserRouter as Router, Route, Routes, Navigate } from 'react-router-dom';
import LoginPage from '../pages/login/LoginPage';
import RegisterPage from '../pages/register/RegisterPage';
import AdminDashboard from '../pages/dashboard/AdminDashboard';
import UserDashboard from '../pages/dashboard/UserDashboard';
import HomePage from '../pages/admin/home/HomePage';
import AccountManagement from '../pages/admin/AccountManagement/AccountManagement';
import DistributionManagement from '../pages/admin/DistributionManagement/DistributionManagement';
import MemberManagement from '../pages/admin/MemberManagement/MemberManagement';
import OrderManagement from '../pages/admin/orderManager/orderManager';
import Categories from '../pages/admin/products/Categories';
import ProductList from '../pages/admin/products/ProductList';
import PrivateRoute from '../components/PrivateRoute';
import AssetManagement from '../pages/admin/AssetManagement/AssetManagement';
import PointsManagement from '../pages/admin/PointsManagement/PointsManagement';
import RoleManagement from '../pages/admin/RoleManagement/RoleManagement';
import RechargeAudit from '../pages/admin/rechargeAudit/rechargeAudit';
function AppRoutes() {
  return (
    <Router>
      <Routes>
        <Route path="/" element={<Navigate to="/login" />} />
        <Route path="/login" element={<LoginPage />} />
        <Route path="/register" element={<RegisterPage />} />
        
        {/* 使用 PrivateRoute 包装需要登录才能访问的路由 */}
        <Route path="/admin" element={
          <PrivateRoute>
            <AdminDashboard />
          </PrivateRoute>
        }>
          <Route index element={<HomePage />} />
          <Route path="dashboard" element={<HomePage />} />
          <Route path="account" element={<AccountManagement />} />
          <Route path="distribution" element={<DistributionManagement />} />
          <Route path="member" element={<MemberManagement />} />
          <Route path="categories" element={<Categories />} />
          <Route path="productList" element={<ProductList />} />
          <Route path="order" element={<OrderManagement />} />
          <Route path="assets" element={<AssetManagement />} />
          <Route path="points" element={<PointsManagement />} />
          <Route path="role" element={<RoleManagement />} />
          <Route path="rechargeAudit" element={<RechargeAudit />} />
        </Route>

        <Route path="/user/dashboard" element={
          <PrivateRoute>
            <UserDashboard />
          </PrivateRoute>
        } />
      </Routes>
    </Router>
  );
}

export default AppRoutes;